
import 'package:flutter/material.dart';
import 'package:flutter_deer/account/iview/recharge_add_iview.dart';
import 'package:flutter_deer/account/models/user_score_deposit_entity.dart';
import 'package:flutter_deer/mvp/base_page_presenter.dart';
import 'package:flutter_deer/net/base_entity.dart';
import 'package:flutter_deer/net/dio_utils.dart';
import 'package:flutter_deer/net/http_api.dart';


class RechargeAddPresenter extends BasePagePresenter<RechargeAddIMvpView> {

  @override
  void initState() {
  }

  Future<dynamic> saveRecharge(String? cardNo,String? bankId,double? score) async {
    UserScoreDepositEntity userScoreDepositEntity = UserScoreDepositEntity();
    userScoreDepositEntity.cardNo = cardNo;
    userScoreDepositEntity.bankId = bankId;
    userScoreDepositEntity.score = score;
    WidgetsBinding.instance.addPostFrameCallback((_) {
      requestNetwork<OperatorBaseEntity>(Method.post,
          url: HttpApi.saveRecharge,
          params: userScoreDepositEntity.toJson(),
          onSuccess: (data) {
            if(data!.data==true){
              view.saveRechargeSuccess();
            }else{
              view.saveRechargeFail();
            }
          },
          onError: (code,msg){

          }
      );
    });
  }

}